package app

import (
	"strings"
)

type ValidError struct {
	Key     string
	Message string
}

type ValidErrors []*ValidError

func (v *ValidError) Error() string {
	return v.Message
}

func (v ValidErrors) Error() string {
	return strings.Join(v.Errors(), ",")
}

func (v ValidErrors) Errors() []string {
	errs := make([]string, 0, len(v))
	for _, err := range v {
		errs = append(errs, err.Error())
	}

	return errs
}

func (r *Response) Bind(v interface{}) error {
	if err := r.Ctx.Bind(v); err != nil {
		return err
	}

	return nil
}
